
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Large finds - (Potentially) active alien machinery from the dawn of time

/datum/artifact_find
	var/artifact_id
	var/artifact_find_type
	var/artifact_detect_range

/datum/artifact_find/New()
	artifact_detect_range = rand(5,300)

	artifact_id = "[pick("kappa","sigma","antaeres","beta","omicron","iota","epsilon","omega","gamma","delta","tau","alpha")]-[rand(1,999)]"

	artifact_find_type = pick(\
	5;/obj/structure/constructshell,\
	25;/obj/structure/closet/crate/secure/loot,\
	50;/obj/structure/cult/pylon,\
	100;/obj/machinery/giga_drill,\
	500;/obj/machinery/replicator,\
	1000;/obj/machinery/artifact)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Boulders - sometimes turn up after excavating turf - excavate further to try and find large xenoarch finds

/obj/structure/boulder
	name = "rocky debris"
	desc = "Mysterious leftover rock. I wonder what could be inside."
	icon = 'icons/turf/mining.dmi'
	icon_state = "boulder1"
	density = 1
	opacity = 1
	var/datum/artifact_find/artifact_find

/obj/structure/boulder/New()
	icon_state = "boulder[rand(1,4)]"

/obj/structure/boulder/attackby(obj/item/weapon/W as obj, mob/user as mob)
	if (istype(W, /obj/item/weapon/pickaxe))
		var/obj/item/weapon/pickaxe/P = W

		user << "\red You start [P.drill_verb] [src]."

		if(!do_after(user,P.digspeed))
			return

		user << "\blue You finish [P.drill_verb] [src]."

		if(artifact_find)
			var/spawn_type = artifact_find.artifact_find_type
			var/obj/O = new spawn_type(get_turf(src))
			if(istype(O,/obj/machinery/artifact))
				var/obj/machinery/artifact/X = O
				if(X.my_effect)
					X.my_effect.artifact_id = artifact_find.artifact_id
			src.visible_message("<font color='red'><b>[src] suddenly crumbles away.</b></font>")
		else
			user.visible_message("<font color='red'><b>[src] suddenly crumbles away into dust.</b></font>")
		del(src)
